home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / SETUP / US / CBUILDER / DATA.Z / EXCPT.H < prev    next >
C/C++ Source or Header  |  1997-02-13  |  13KB  |  410 lines

  1. /***
  2. *excpt.h - defines exception values, types and routines
  3. *
  4. *Purpose:
  5. *   This file contains the definitions and prototypes for the compiler-
  6. *   dependent intrinsics, support functions and keywords which implement
  7. *   the structured exception handling extensions.
  8. *
  9. ****/
  10.  
  11. /*
  12.  *      C/C++ Run Time Library - Version 8.0
  13.  *
  14.  *      Copyright (c) 1990, 1997 by Borland International
  15.  *      All Rights Reserved.
  16.  *
  17.  */
  18.  
  19.  
  20.  
  21. #ifndef __EXCPT_H
  22. #define __EXCPT_H
  23. #pragma option -b
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. #if defined(__BORLANDC__) && !defined(__FLAT__)
  30.  
  31. #if !defined(__WINDOWS_H)
  32. typedef unsigned char       BYTE;
  33. typedef unsigned long       DWORD;
  34. typedef void __far *        LPVOID;
  35. typedef unsigned int        UINT;
  36. typedef DWORD  __far *      LPDWORD;
  37. #define WINAPI              _far _pascal
  38. #endif
  39.  
  40. /* From WINNT.H */
  41.  
  42. //
  43. //  Define the size of the 80387 save area, which is in the context frame.
  44. //
  45.  
  46. #define SIZE_OF_80387_REGISTERS      80
  47.  
  48. typedef struct _FLOATING_SAVE_AREA {
  49.     DWORD   ControlWord;
  50.     DWORD   StatusWord;
  51.     DWORD   TagWord;
  52.     DWORD   ErrorOffset;
  53.     DWORD   ErrorSelector;
  54.     DWORD   DataOffset;
  55.     DWORD   DataSelector;
  56.     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
  57.     DWORD   Cr0NpxState;
  58. } FLOATING_SAVE_AREA;
  59.  
  60. //
  61. // Context Frame
  62. //
  63. //  This frame has a several purposes: 1) it is used as an argument to
  64. //  NtContinue, 2) is is used to constuct a call frame for APC delivery,
  65. //  and 3) it is used in the user level thread creation routines.
  66. //
  67. //  The layout of the record conforms to a standard call frame.
  68. //
  69.  
  70. typedef struct _CONTEXT {
  71.  
  72.     //
  73.     // The flags values within this flag control the contents of
  74.     // a CONTEXT record.
  75.     //
  76.     // If the context record is used as an input parameter, then
  77.     // for each portion of the context record controlled by a flag
  78.     // whose value is set, it is assumed that that portion of the
  79.     // context record contains valid context. If the context record
  80.     // is being used to modify a threads context, then only that
  81.     // portion of the threads context will be modified.
  82.     //
  83.     // If the context record is used as an IN OUT parameter to capture
  84.     // the context of a thread, then only those portions of the thread's
  85.     // context corresponding to set flags will be returned.
  86.     //
  87.     // The context record is never used as an OUT only parameter.
  88.     //
  89.  
  90.     DWORD ContextFlags;
  91.  
  92.     //
  93.     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  94.     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
  95.     // included in CONTEXT_FULL.
  96.     //
  97.  
  98.     DWORD   Dr0;
  99.     DWORD   Dr1;
  100.     DWORD   Dr2;
  101.     DWORD   Dr3;
  102.     DWORD   Dr6;
  103.     DWORD   Dr7;
  104.  
  105.     //
  106.     // This section is specified/returned if the
  107.     // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  108.     //
  109.  
  110.     FLOATING_SAVE_AREA FloatSave;
  111.  
  112.     //
  113.     // This section is specified/returned if the
  114.     // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  115.     //
  116.  
  117.     DWORD   SegGs;
  118.     DWORD   SegFs;
  119.     DWORD   SegEs;
  120.     DWORD   SegDs;
  121.  
  122.     //
  123.     // This section is specified/returned if the
  124.     // ContextFlags word contians the flag CONTEXT_INTEGER.
  125.     //
  126.  
  127.     DWORD   Edi;
  128.     DWORD   Esi;
  129.     DWORD   Ebx;
  130.     DWORD   Edx;
  131.     DWORD   Ecx;
  132.     DWORD   Eax;
  133.  
  134.     //
  135.     // This section is specified/returned if the
  136.     // ContextFlags word contians the flag CONTEXT_CONTROL.
  137.     //
  138.  
  139.     DWORD   Ebp;
  140.     DWORD   Eip;
  141.     DWORD   SegCs;              // MUST BE SANITIZED
  142.     DWORD   EFlags;             // MUST BE SANITIZED
  143.     DWORD   Esp;
  144.     DWORD   SegSs;
  145.  
  146. } CONTEXT;
  147.  
  148.  
  149. typedef CONTEXT *PCONTEXT;
  150.  
  151. /* From WINNT.H */
  152. #define STATUS_WAIT_0                    ((DWORD   )0x00000000L)
  153. #define STATUS_ABANDONED_WAIT_0          ((DWORD   )0x00000080L)
  154. #define STATUS_USER_APC                  ((DWORD   )0x000000C0L)
  155. #define STATUS_TIMEOUT                   ((DWORD   )0x00000102L)
  156. #define STATUS_PENDING                   ((DWORD   )0x00000103L)
  157. #define STATUS_DATATYPE_MISALIGNMENT     ((DWORD   )0x80000002L)
  158. #define STATUS_BREAKPOINT                ((DWORD   )0x80000003L)
  159. #define STATUS_SINGLE_STEP               ((DWORD   )0x80000004L)
  160. #define STATUS_ACCESS_VIOLATION          ((DWORD   )0xC0000005L)
  161. #define STATUS_IN_PAGE_ERROR             ((DWORD   )0xC0000006L)
  162. #define STATUS_NO_MEMORY                 ((DWORD   )0xC0000017L)
  163. #define STATUS_ILLEGAL_INSTRUCTION       ((DWORD   )0xC000001DL)
  164. #define STATUS_NONCONTINUABLE_EXCEPTION  ((DWORD   )0xC0000025L)
  165. #define STATUS_INVALID_DISPOSITION       ((DWORD   )0xC0000026L)
  166. #define STATUS_ARRAY_BOUNDS_EXCEEDED     ((DWORD   )0xC000008CL)
  167. #define STATUS_FLOAT_DENORMAL_OPERAND    ((DWORD   )0xC000008DL)
  168. #define STATUS_FLOAT_DIVIDE_BY_ZERO      ((DWORD   )0xC000008EL)
  169. #define STATUS_FLOAT_INEXACT_RESULT      ((DWORD   )0xC000008FL)
  170. #define STATUS_FLOAT_INVALID_OPERATION   ((DWORD   )0xC0000090L)
  171. #define STATUS_FLOAT_OVERFLOW            ((DWORD   )0xC0000091L)
  172. #define STATUS_FLOAT_STACK_CHECK         ((DWORD   )0xC0000092L)
  173. #define STATUS_FLOAT_UNDERFLOW           ((DWORD   )0xC0000093L)
  174. #define STATUS_INTEGER_DIVIDE_BY_ZERO    ((DWORD   )0xC0000094L)
  175. #define STATUS_INTEGER_OVERFLOW          ((DWORD   )0xC0000095L)
  176. #define STATUS_PRIVILEGED_INSTRUCTION    ((DWORD   )0xC0000096L)
  177. #define STATUS_STACK_OVERFLOW            ((DWORD   )0xC00000FDL)
  178. #define STATUS_CONTROL_C_EXIT            ((DWORD   )0xC000013AL)
  179.  
  180. /* From WINNT.H */
  181. #define EXCEPTION_CONTINUABLE        0      // Continuable exception
  182. #define EXCEPTION_NONCONTINUABLE     0x1    // Noncontinuable exception
  183. #define EXCEPTION_MAXIMUM_PARAMETERS 15     // maximum number of exception parameters
  184.  
  185. //
  186. // Exception record definition.
  187. //
  188.  
  189. typedef struct _EXCEPTION_RECORD {
  190.     DWORD ExceptionCode;
  191.     DWORD ExceptionFlags;
  192.     struct _EXCEPTION_RECORD __ss *ExceptionRecord;
  193.     LPVOID ExceptionAddress;
  194.     UINT NumberParameters;
  195.     DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  196. } EXCEPTION_RECORD;
  197.  
  198. typedef EXCEPTION_RECORD __ss *PEXCEPTION_RECORD;
  199.  
  200. //
  201. // Typedef for pointer returned by exception_info()
  202. //
  203.  
  204. typedef struct _EXCEPTION_POINTERS {
  205.     PEXCEPTION_RECORD ExceptionRecord;
  206.     PCONTEXT ContextRecord;
  207. } EXCEPTION_POINTERS, __ss *PEXCEPTION_POINTERS;
  208.  
  209.  
  210. /* From WINBASE.H */
  211. #define EXCEPTION_ACCESS_VIOLATION      STATUS_ACCESS_VIOLATION
  212. #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
  213. #define EXCEPTION_BREAKPOINT            STATUS_BREAKPOINT
  214. #define EXCEPTION_SINGLE_STEP           STATUS_SINGLE_STEP
  215. #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
  216. #define EXCEPTION_FLT_DENORMAL_OPERAND  STATUS_FLOAT_DENORMAL_OPERAND
  217. #define EXCEPTION_FLT_DIVIDE_BY_ZERO    STATUS_FLOAT_DIVIDE_BY_ZERO
  218. #define EXCEPTION_FLT_INEXACT_RESULT    STATUS_FLOAT_INEXACT_RESULT
  219. #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
  220. #define EXCEPTION_FLT_OVERFLOW          STATUS_FLOAT_OVERFLOW
  221. #define EXCEPTION_FLT_STACK_CHECK       STATUS_FLOAT_STACK_CHECK
  222. #define EXCEPTION_FLT_UNDERFLOW         STATUS_FLOAT_UNDERFLOW
  223. #define EXCEPTION_INT_DIVIDE_BY_ZERO    STATUS_INTEGER_DIVIDE_BY_ZERO
  224. #define EXCEPTION_INT_OVERFLOW          STATUS_INTEGER_OVERFLOW
  225. #define EXCEPTION_PRIV_INSTRUCTION      STATUS_PRIVILEGED_INSTRUCTION
  226. #define EXCEPTION_IN_PAGE_ERROR         STATUS_IN_PAGE_ERROR
  227.  
  228. void
  229. __cdecl __far
  230. RaiseException(
  231.     DWORD dwExceptionCode,
  232.     DWORD dwExceptionFlags,
  233.     DWORD nNumberOfArguments,
  234.     const LPDWORD lpArguments
  235.     );
  236.  
  237. long
  238. WINAPI
  239. UnhandledExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo);
  240.  
  241. typedef long (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
  242.    PEXCEPTION_POINTERS ExceptionInfo
  243.    );
  244. typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
  245.  
  246. LPTOP_LEVEL_EXCEPTION_FILTER
  247. WINAPI
  248. SetUnhandledExceptionFilter(
  249.    LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
  250.    );
  251.  
  252. #endif  /* __BORLANDC__ && !__FLAT__ */
  253.  
  254.  
  255. /*
  256.  * Conditional macro definition for function calling